Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of methods login and findByEmail #914

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nastasiiaKulinich
Copy link

No description provided.

Copy link

@Ivan95kos Ivan95kos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job overall

@@ -11,6 +13,11 @@ public class AuthenticationService {
* Return false in any other cases.
*/
public boolean login(String email, String password) {
User user = new UserService().findByEmail(email);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UserService must be a class field

Suggested change
User user = new UserService().findByEmail(email);
User user = userService.findByEmail(email);

public class AuthenticationService {
private UserService userService;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. field is not initialized
  2. make it final

Comment on lines 20 to 23
if (user != null) {
return user.getPassword().equals(password);
}
return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good code is simple code. think about how to make it inline

Comment on lines 20 to 23
if (user != null && user.getPassword().equals(password)) {
return true;
}
return false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewrite it in one line

return false;
User user = userService.findByEmail(email);

return (user != null && user.getPassword().equals(password)) ? true : false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really not bad try, but... seriously?))

Suggested change
return (user != null && user.getPassword().equals(password)) ? true : false;
return user != null && user.getPassword().equals(password));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants